#ifndef THINK_THINK_CONSOLE_OUTPUT_FORMATTER_STYLE_H
#define THINK_THINK_CONSOLE_OUTPUT_FORMATTER_STYLE_H

static char* think_console_output_formatter_style =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: yunwuxin <448901948@qq.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think\\console\\output\\formatter;\n"
	"\n"
	"class Style\n"
	"{\n"
	"\n"
	"    private static $availableForegroundColors = [\n"
	"        \'black\'   => [\'set\' => 30, \'unset\' => 39],\n"
	"        \'red\'     => [\'set\' => 31, \'unset\' => 39],\n"
	"        \'green\'   => [\'set\' => 32, \'unset\' => 39],\n"
	"        \'yellow\'  => [\'set\' => 33, \'unset\' => 39],\n"
	"        \'blue\'    => [\'set\' => 34, \'unset\' => 39],\n"
	"        \'magenta\' => [\'set\' => 35, \'unset\' => 39],\n"
	"        \'cyan\'    => [\'set\' => 36, \'unset\' => 39],\n"
	"        \'white\'   => [\'set\' => 37, \'unset\' => 39],\n"
	"    ];\n"
	"    private static $availableBackgroundColors = [\n"
	"        \'black\'   => [\'set\' => 40, \'unset\' => 49],\n"
	"        \'red\'     => [\'set\' => 41, \'unset\' => 49],\n"
	"        \'green\'   => [\'set\' => 42, \'unset\' => 49],\n"
	"        \'yellow\'  => [\'set\' => 43, \'unset\' => 49],\n"
	"        \'blue\'    => [\'set\' => 44, \'unset\' => 49],\n"
	"        \'magenta\' => [\'set\' => 45, \'unset\' => 49],\n"
	"        \'cyan\'    => [\'set\' => 46, \'unset\' => 49],\n"
	"        \'white\'   => [\'set\' => 47, \'unset\' => 49],\n"
	"    ];\n"
	"    private static $availableOptions = [\n"
	"        \'bold\'       => [\'set\' => 1, \'unset\' => 22],\n"
	"        \'underscore\' => [\'set\' => 4, \'unset\' => 24],\n"
	"        \'blink\'      => [\'set\' => 5, \'unset\' => 25],\n"
	"        \'reverse\'    => [\'set\' => 7, \'unset\' => 27],\n"
	"        \'conceal\'    => [\'set\' => 8, \'unset\' => 28],\n"
	"    ];\n"
	"\n"
	"    private $foreground;\n"
	"    private $background;\n"
	"    private $options = [];\n"
	"\n"
	"    /**\n"
	"     * 初始化输出的样式\n"
	"     * @param string|null $foreground 字体颜色\n"
	"     * @param string|null $background 背景色\n"
	"     * @param array       $options    格式\n"
	"     * @api\n"
	"     */\n"
	"    public function __construct($foreground = null, $background = null, array $options = [])\n"
	"    {\n"
	"        if (null !== $foreground) {\n"
	"            $this->setForeground($foreground);\n"
	"        }\n"
	"        if (null !== $background) {\n"
	"            $this->setBackground($background);\n"
	"        }\n"
	"        if (count($options)) {\n"
	"            $this->setOptions($options);\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置字体颜色\n"
	"     * @param string|null $color 颜色名\n"
	"     * @throws \\InvalidArgumentException\n"
	"     * @api\n"
	"     */\n"
	"    public function setForeground($color = null)\n"
	"    {\n"
	"        if (null === $color) {\n"
	"            $this->foreground = null;\n"
	"\n"
	"            return;\n"
	"        }\n"
	"\n"
	"        if (!isset(static::$availableForegroundColors[$color])) {\n"
	"            throw new \\InvalidArgumentException(sprintf(\'Invalid foreground color specified: \"%s\". Expected one of (%s)\', $color, implode(\', \', array_keys(static::$availableForegroundColors))));\n"
	"        }\n"
	"\n"
	"        $this->foreground = static::$availableForegroundColors[$color];\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置背景色\n"
	"     * @param string|null $color 颜色名\n"
	"     * @throws \\InvalidArgumentException\n"
	"     * @api\n"
	"     */\n"
	"    public function setBackground($color = null)\n"
	"    {\n"
	"        if (null === $color) {\n"
	"            $this->background = null;\n"
	"\n"
	"            return;\n"
	"        }\n"
	"\n"
	"        if (!isset(static::$availableBackgroundColors[$color])) {\n"
	"            throw new \\InvalidArgumentException(sprintf(\'Invalid background color specified: \"%s\". Expected one of (%s)\', $color, implode(\', \', array_keys(static::$availableBackgroundColors))));\n"
	"        }\n"
	"\n"
	"        $this->background = static::$availableBackgroundColors[$color];\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置字体格式\n"
	"     * @param string $option 格式名\n"
	"     * @throws \\InvalidArgumentException When the option name isn\'t defined\n"
	"     * @api\n"
	"     */\n"
	"    public function setOption($option)\n"
	"    {\n"
	"        if (!isset(static::$availableOptions[$option])) {\n"
	"            throw new \\InvalidArgumentException(sprintf(\'Invalid option specified: \"%s\". Expected one of (%s)\', $option, implode(\', \', array_keys(static::$availableOptions))));\n"
	"        }\n"
	"\n"
	"        if (!in_array(static::$availableOptions[$option], $this->options)) {\n"
	"            $this->options[] = static::$availableOptions[$option];\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 重置字体格式\n"
	"     * @param string $option 格式名\n"
	"     * @throws \\InvalidArgumentException\n"
	"     */\n"
	"    public function unsetOption($option)\n"
	"    {\n"
	"        if (!isset(static::$availableOptions[$option])) {\n"
	"            throw new \\InvalidArgumentException(sprintf(\'Invalid option specified: \"%s\". Expected one of (%s)\', $option, implode(\', \', array_keys(static::$availableOptions))));\n"
	"        }\n"
	"\n"
	"        $pos = array_search(static::$availableOptions[$option], $this->options);\n"
	"        if (false !== $pos) {\n"
	"            unset($this->options[$pos]);\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 批量设置字体格式\n"
	"     * @param array $options\n"
	"     */\n"
	"    public function setOptions(array $options)\n"
	"    {\n"
	"        $this->options = [];\n"
	"\n"
	"        foreach ($options as $option) {\n"
	"            $this->setOption($option);\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 应用样式到文字\n"
	"     * @param string $text 文字\n"
	"     * @return string\n"
	"     */\n"
	"    public function apply($text)\n"
	"    {\n"
	"        $setCodes   = [];\n"
	"        $unsetCodes = [];\n"
	"\n"
	"        if (null !== $this->foreground) {\n"
	"            $setCodes[]   = $this->foreground[\'set\'];\n"
	"            $unsetCodes[] = $this->foreground[\'unset\'];\n"
	"        }\n"
	"        if (null !== $this->background) {\n"
	"            $setCodes[]   = $this->background[\'set\'];\n"
	"            $unsetCodes[] = $this->background[\'unset\'];\n"
	"        }\n"
	"        if (count($this->options)) {\n"
	"            foreach ($this->options as $option) {\n"
	"                $setCodes[]   = $option[\'set\'];\n"
	"                $unsetCodes[] = $option[\'unset\'];\n"
	"            }\n"
	"        }\n"
	"\n"
	"        if (0 === count($setCodes)) {\n"
	"            return $text;\n"
	"        }\n"
	"\n"
	"        return sprintf(\"\\033[%sm%s\\033[%sm\", implode(\';\', $setCodes), $text, implode(\';\', $unsetCodes));\n"
	"    }\n"
	"}\n"
	"\n"
;
#endif